package org.example.tools;

import org.apache.flink.table.api.EnvironmentSettings;
import org.apache.flink.table.api.TableEnvironment;

public class PaimonBatchQuery {
    public static void main(String[] args) {
        final EnvironmentSettings settings = EnvironmentSettings.newInstance().inBatchMode().build();
        settings.getConfiguration().setString("table.display.max-column-width", "100");
        TableEnvironment tableEnv = TableEnvironment.create(settings);

        String sql1 = "CREATE CATALOG paimon WITH (\n" +
                "    'type' = 'paimon',\n" +
                "    'warehouse' = 'file:///tmp/paimon'\n" +
                ");\n";
        System.out.println(sql1);
        tableEnv.executeSql(sql1);

        String sql2 = "select count(1) as cnt from `paimon`.`default`.`user_behavior2`;";
        String sql3 = "SELECT * FROM `paimon`.`default`.`user_behavior$snapshots`;";
        System.out.println(sql2);
        tableEnv.executeSql(sql2).print();
//        tableEnv.executeSql(sql3).print();
    }
}
